<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <div>
      <div id="app1"></div>
      <div id="app2"></div>
      <div id="app3"></div>
    </div>
    <script src="../utils/js/old_version/react.development.js"></script>
    <script src="../utils/js/old_version/react-dom.development.js"></script>
    <script src="../utils/js/old_version/prop-types.js"></script>
    <script src="../utils/js/old_version/babel.min.js"></script>
    <script type="text/babel">
      class Person extends React.Component {
        render() {
          const { name, age, sex } = this.props;
          return (
            <ul>
              <li> name: {name}</li>
              <li> age: {age + 1}</li>
              <li> sex: {sex}</li>
            </ul>
          );
        }
      }
      //   对组件传递的标签属性的类型做限制，类型与是否必传  16版本之前 name: React.PropTypes.string，16之后使用了prop-types依赖包,专门对标签属性进行限制
      Person.propTypes = {
        name: PropTypes.string.isRequired,
        age: PropTypes.number,
        sex: PropTypes.string,
        speak: PropTypes.func, // 设置函数 用 func
      };
      Person.defaultProps = {
        sex: "不男不女",
      };
      ReactDOM.render(
        <Person name="juser" age={18} />,
        document.getElementById("app1")
      );
      ReactDOM.render(
        <Person name="xx" age={20} sex="女" />,
        document.getElementById("app2")
      );
      const p = { name: "ll", age: 35, sex: "女" };
      ReactDOM.render(<Person {...p} />, document.getElementById("app3"));
    </script>
  </body>
</html>
